package org.huatek.anders.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.util.Date;

/**
 * @author anders
 * @date 2018-12-03 13:47
 **/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("sys_user")
public class UserEntity extends BaseEntity{
    private static final long serialVersionUID = -9051166973215131802L;

    protected String userName;
    protected String password;
    @JsonIgnore
    protected String salt;
    protected String mobile;
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    protected Date loginTime;



    /**
     * 重新对盐重新进行了定义，用户名+salt，这样就更加不容易被破解
     * 密码盐.
     */
    @JsonIgnore
    public String getCredentialsSalt(){
        return this.userName + this.salt;
    }
}
